package soar.basic;

public class Misc
{
    public static final int BIT_OF_BYTE=8; 

    public static final int NAME_SIZE=30; 
    public static final int LONG_NAME_SIZE=200;

    public static String ExpandToString(byte[] b)
    {/*{{{*/
        String s="";
        String stmp;
        for (int i=0; i<b.length; ++i)
        {
            stmp=Integer.toHexString(b[i] & 0xFF);
            if (stmp.length() == 1)
                stmp="0"+stmp;
            s+=stmp;
        }
        return s.toUpperCase();
    }/*}}}*/

    public static byte[] CollapseFromString(String s)
    {/*{{{*/
        int bsize=s.length()/2;
        byte[] b=new byte[bsize];
        for (int i=0; i<bsize; i++)
        {
            b[i]=(byte)Integer.parseInt(s.substring(i*2, (i+1)*2), 16);
        }
        return b;
    } /*}}}*/
}
